package com.bstek.bdf4.mq.publisher.controller;

import com.bstek.bdf2.core.mq.publisher.BstekSendMessage;
import com.bstek.bdf2.core.mq.publisher.MessageInfo;
import com.bstek.bdf4.builder.Builder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * @Title: BstekPubLisherController
 * @Package: com.bstek.bdf4.mq.publisher.controller
 * @Description:
 * @Author: zxq
 * @Date: 2024/2/5 - 15:11
 */

@RestController
@RequestMapping("/api/mq")
public class BstekPubLisherController {

    @Resource
    private BstekSendMessage bstekSendMessage;

    @GetMapping("/send")
    public void sendMessage(){
        MessageInfo info = Builder.builder(MessageInfo::new)
                .with(MessageInfo::setRoutingKey, "simple.queue")
                .with(MessageInfo::setMessage,"测试")
                .build();
        MessageInfo messageInfo = new MessageInfo();
        messageInfo.setRoutingKey("simple.queue");
        HashMap<String, Object> map = new HashMap<>();
        map.put("name","jack");
        map.put("age",28);
        messageInfo.setMessage(info);
        bstekSendMessage.send(messageInfo);
    }
}
